package com.sky.wsp.camel;

import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.core.io.file.PathUtil;

import java.io.File;
import java.io.FileFilter;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @desccription 针对JavaBean属性、getr/set方法，实现snake风格转换为camel风格
 * @auth wangshaopeng@talkweb.com.cn
 * @date 2022/12/20
 */
public class FileFilterUtils01 {

    private static String sourcePath = "C:\\Users\\24044\\Desktop\\29sql.sql";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-insert-inn_dps_posts.sql";
//    private static String startWith = "INSERT INTO `forum-wsp`.`inn_dps_posts`";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-update-inn_dps_posts.sql";
//    private static String startWith = "UPDATE `forum-wsp`.`inn_dps_posts`";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-insert-inn_dps_wiki.sql";
//    private static String startWith = "INSERT INTO `forum-wsp`.`inn_dps_wiki`";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-update-inn_dps_wiki.sql";
//    private static String startWith = "UPDATE `forum-wsp`.`inn_dps_wiki`";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-insert-inn_dps_resource.sql";
//    private static String startWith = "INSERT INTO `forum-wsp`.`inn_dps_resource`";

//    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-insert-inn_dps_wiki_node.sql";
//    private static String startWith = "INSERT INTO `forum-wsp`.`inn_dps_wiki_node`";

    private static String targetPath = "C:\\Users\\24044\\Desktop\\29sql-update-inn_dps_wiki_node.sql";
    private static String startWith = "UPDATE `forum-wsp`.`inn_dps_wiki_node`";

    private static Integer count = 0;

    public static void main(String[] args) {
        System.out.println("开始处理...");
        StringBuilder sb = new StringBuilder();
        FileReader fileReader = new FileReader(sourcePath);
        List<String> lines = fileReader.readLines();
        if (lines.isEmpty()) {
            return;
        }
        for (String l : lines) {
            if(l.startsWith(startWith)){
                sb.append(l).append("\r\n");
                count++;
            }
        }
        FileWriter writer = new FileWriter(targetPath);
        writer.write(sb.toString());
        System.out.println("================总共处理" + "【" + count + "】行SQL!!!=======================");
    }
}
